// pages/biz/selectAdviser/selectAdviser.js
//引入请求接口文件
import Serv from './selectAdviserServ';
var regeneratorRuntime = require("../../../lib/js/runtime-module.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
    counselorList: [],
    selectList:[],
    pointlist:[],
    adviserIndex:null
  },
  todetail(e){
    console.log(e.currentTarget.dataset.id)
    wx.navigateTo({
      url: '/pages/biz/evaluationDetail/evaluationDetail?id='+ e.currentTarget.dataset.id,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  radioChange(e){
    let pages = getCurrentPages();//当前页面
    let prevPage = pages[pages.length - 2];//上一页面
    let { counselorList } = this.data;
    let index = e.detail.value;
    let counselorData = counselorList[index]
    prevPage.setData({//直接给上移页面赋值
      dviser: counselorData.name,
      query:{
        ...prevPage.data.query,
        counselorId: counselorData.counselorId,
        counselorMobile: counselorData.mobile,
        counselorName: counselorData.name
      },
      adviserIndex:index
    });
    console.log(prevPage,"prevPage")
    wx.navigateBack({//返回
      delta: 1
    })
  },
  
  async getCounselor(ProductId){
    let result = await Serv.counselorGet(ProductId)
    if (result.success && result.rows) {
      this.setData({ counselorList: result.rows, selectList: result.rows})

    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getCounselor(options.ProductId)
    console.log(options.adviserIndex)
    this.setData({
      adviserIndex: options.adviserIndex
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})